package com.Moch.AbstractTest;

import com.Moch.Abstract.Circle;

public class Test {

    public static void main(String[] args) {
        Cycle cycle1 = new Cycle(2);
        cycle1.calcArea();
        double p = cycle1.getArea();
//        System.out.println(p);

        Shape[] shapes = {new Rect(2, 3), new Cycle(3), new Cycle(9), new Triangle(2,3, 4), cycle1, new Rect(4 , 5)};
        for(Shape x : shapes) {
            x.draw();
            x.calcArea();
            System.out.println("area = " + x.getArea());
            System.out.println("-----");
        }

        System.out.println("======");
        Xia(shapes);
    }

    public static void Xia(Shape[] shape) {
        for(Shape x : shape) {
            if(x instanceof Rect) {
                Rect rect1 = (Rect) x;
                rect1.draw();
            } else if(x instanceof Cycle) {
                Cycle cycle1 = (Cycle) x;
                cycle1.draw();
            } else if(x instanceof Triangle) {
                Triangle triangle1 = (Triangle) x;
                triangle1.draw();
            } else {
                return;
            }
        }
    }

}
